<template>
  <div>
    <van-tabbar
      v-model="active"
      route
      active-color="rgb(12,52,186)"
      inactive-color="rgb(100,101,102)"
    >
      <van-tabbar-item
        v-for="(v, i) in navArr"
        :key="i"
        :to="{ name: v.toName }"
      >
        <span>{{ v.title }}</span>
        <template #icon="props">
          <img :src="props.active ? v.activeIcon : v.inactiveIcon" />
        </template>
      </van-tabbar-item>
    </van-tabbar>
    <div class="backdrop" :style="{ 'min-height': minHeight }">
      <router-view />
    </div>
  </div>
</template>

<script>
export default {
  name: "Main",
  data() {
    return {
      active: 0,
      minHeight: innerHeight + "px",
      navArr: [
        {
          title: "首页",
          activeIcon: require("../assets/images/home_active.png"),
          inactiveIcon: require("../assets/images/home.png"),
          toName: "Home",
        },
        {
          title: "菜单",
          activeIcon: require("../assets/images/menu_active.png"),
          inactiveIcon: require("../assets/images/menu.png"),
          toName: "Menu",
        },
        {
          title: "购物袋",
          activeIcon: require("../assets/images/shopbag_active.png"),
          inactiveIcon: require("../assets/images/shopbag.png"),
          toName: "Shopbag",
        },
        {
          title: "我的",
          activeIcon: require("../assets/images/my_active.png"),
          inactiveIcon: require("../assets/images/my.png"),
          toName: "My",
        },
      ],
    };
  },
  methods: {
    getIndex() {
      return this;
    },
  },
};
</script>

<style lang="less" scoped>
.backdrop {
  margin: 0;
  background-color: rgb(245, 245, 245);
}
</style>